package com.base;

import java.io.IOException;

import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import com.method.DmMethod;

public class Dm extends Com<DmMethod> {

	@Override
	protected String setComName() {
		return "dm.dmsoft";
	}

	/**
	 * 大漠调用
	 * 
	 * @param method 方法名
	 * @param params 参数
	 * @return
	 */
	@Override
	public String call(DmMethod method, Object... params) {
		Variant call = null;
		if(params!=null&&params.length>0) {
			call = Dispatch.call(com, method.name(), params);
		}else {
			call = Dispatch.call(com, method.name());
		}
		return call.toString();
	}

	@Override
	protected void reg() {
		Runtime rt = Runtime.getRuntime();
	    try {
			rt.exec( Base.PATH +"nircmd32/nircmd.exe elevate  regsvr32 /s " + Base.PATH + "dm/dm.dll");
			System.out.println("reg dm success！");
	    } catch (Exception e) {
	    	try {
				rt.exec( Base.PATH +"nircmd64/nircmd.exe elevate  regsvr32 /s " + Base.PATH + "dm/dm.dll");
				System.out.println("reg dm success！");
	    	} catch (IOException e1) {
				System.out.println("reg dm fail！");
			}
		}
		
	}

}
